package training_camp.day2.kama58;

import java.util.Scanner;

/**
 * description :
 * author Ahang :
 * create : 2025-11-20 14:29
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n  = scanner.nextInt();
        int[] arr = new int[n];
        arr[0] = scanner.nextInt();
        for (int i = 1 ;i< n;i++){
            int x = scanner.nextInt();
            arr[i] = arr[i-1]+x ;
        }
        while(scanner.hasNextInt()){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if (a==0){
                System.out.println(arr[b]);
            }
            else {
                System.out.println(arr[b] - arr[a-1]);
            }
        }
        scanner.close();
    }
}
